<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile
/**
 * @var \Magento\Payment\Block\Adminhtml\Transparent\Form $block
 */
$code = $block->escapeHtml($block->getMethodCode());
$ccType = $block->getInfoData('cc_type');
$ccExpMonth = $block->getInfoData('cc_exp_month');
$ccExpYear = $block->getInfoData('cc_exp_year');
?>
<fieldset class="admin__fieldset payment-method" id="payment_form_<?php /* @noEscape */ echo $code; ?>"
          style="display:none">
    <div class="field-type admin__field _required">
        <label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_type">
            <span><?php echo $block->escapeHtml(__('Credit Card Type')); ?></span>
        </label>
        <div class="admin__field-control">
            <select id="<?php /* @noEscape */ echo $code; ?>_cc_type" name="payment[cc_type]"
                    class="required-entry validate-cc-type-select admin__control-select">
                <option value=""></option>
                <?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?>
                    <option value="<?php echo $block->escapeHtml($typeCode); ?>" <?php if ($typeCode == $ccType): ?>selected="selected"<?php endif ?>>
                        <?php echo $block->escapeHtml($typeName); ?>
                    </option>
                <?php endforeach ?>
            </select>
        </div>
    </div>
    <div class="field-number admin__field _required">
        <label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_number">
            <span><?php echo $block->escapeHtml(__('Credit Card Number')); ?></span>
        </label>
        <div class="admin__field-control">
            <input type="text" id="<?php /* @noEscape */ echo $code; ?>_cc_number" name="payment[cc_number]"
                   title="<?php echo $block->escapeHtml(__('Credit Card Number')); ?>" class="admin__control-text validate-cc-number"
                   value="<?php /* @noEscape */ echo $block->getInfoData('cc_number'); ?>"/>
        </div>
    </div>
    <div class="field-date admin__field _required">
        <label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_expiration">
            <span><?php echo $block->escapeHtml(__('Expiration Date')); ?></span>
        </label>
        <div class="admin__field-control">
            <select id="<?php /* @noEscape */ echo $code ?>_expiration" name="payment[cc_exp_month]"
                    class="admin__control-select admin__control-select-month validate-cc-exp required-entry">
                <?php foreach ($block->getCcMonths() as $k => $v): ?>
                    <option value="<?php echo $block->escapeHtml($k); ?>"
                            <?php if ($k == $ccExpMonth): ?>selected="selected"<?php endif ?>>
                        <?php echo $block->escapeHtml($v); ?>
                    </option>
                <?php endforeach; ?>
            </select>
            <select id="<?php /* @noEscape */ echo $code ?>_expiration_yr" name="payment[cc_exp_year]"
                    class="admin__control-select admin__control-select-year required-entry">
                <?php foreach ($block->getCcYears() as $k => $v): ?>
                    <option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : '' ?>"
                            <?php if ($k == $ccExpYear): ?>selected="selected"<?php endif ?>>
                        <?php echo $block->escapeHtml($v); ?>
                    </option>
                <?php endforeach ?>
            </select>
        </div>
    </div>

    <?php if ($block->hasVerification()): ?>
        <div class="field-number required admin__field _required">
            <label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_cid">
                <span><?php echo $block->escapeHtml(__('Card Verification Number')); ?></span>
            </label>
            <div class="admin__field-control">
                <input type="text" title="<?php echo $block->escapeHtml(__('Card Verification Number')); ?>"
                       class="required-entry validate-cc-cvn admin__control-cvn admin__control-text"
                       id="<?php /* @noEscape */ echo $code; ?>_cc_cid"
                       name="payment[cc_cid]" value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"/>
            </div>
        </div>
    <?php endif; ?>

    <?php if ($block->hasSsCardType()): ?>
        <div id="<?php /* @noEscape */ echo $code; ?>_cc_type_ss_div">
            <div class="field-type required admin__field _required">
                <label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_issue">
                    <span><?php echo $block->escapeHtml(__('Switch/Solo/Maestro Only')); ?></span>
                </label>
            </div>
            <div class="admin__field field-issue">
                <label class="admin__field-label"
                       for="<?php /* @noEscape */ echo $code; ?>_cc_issue">
                    <span><?php echo $block->escapeHtml(__('Issue Number')); ?></span>
                </label>

                <div class="admin__field-control">
                    <input type="text" title="<?php echo $block->escapeHtml(__('Issue Number')); ?>"
                           class="validate-cc-ukss cvv admin__control-cvv admin__control-text"
                           id="<?php /* @noEscape */ echo $code; ?>_cc_issue" name="payment[cc_ss_issue]" value=""/>
                </div>
            </div>
            <div class="field field-date">
                <label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_start_month">
                    <span><?php echo $block->escapeHtml(__('Start Date')); ?></span>
                </label>
                <div class="admin__field-control">
                    <select id="<?php /* @noEscape */ echo $code; ?>_start_month" name="payment[cc_ss_start_month]"
                            class="validate-cc-ukss admin__control-select admin__control-select-month">
                        <?php foreach ($block->getCcMonths() as $k => $v): ?>
                            <option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : '' ?>"
                                <?php if ($k == $block->getInfoData('cc_ss_start_month')): ?> selected="selected"<?php endif ?>>
                                <?php echo $block->escapeHtml($v); ?>
                            </option>
                        <?php endforeach ?>
                    </select>
                    <select id="<?php /* @noEscape */ echo $code; ?>_start_year" name="payment[cc_ss_start_year]"
                            class="validate-cc-ukss admin__control-select admin__control-select-year">
                        <?php foreach ($block->getSsStartYears() as $k => $v): ?>
                            <option value="<?php /* @noEscape */ echo $block->escapeHtml($k) ? $k : '' ?>"
                                <?php if ($k == $block->getInfoData('cc_ss_start_year')): ?> selected="selected"<?php endif ?>>
                                <?php echo $block->escapeHtml($v); ?>
                            </option>
                        <?php endforeach ?>
                    </select>
                </div>
            </div>

            <div class="adv-container">&nbsp;</div>

            <script>
require(['jquery', 'prototype'], function(jQuery){

    //<![CDATA[
    SSChecked<?php /* @noEscape */ echo $code; ?> = function() {
        var elm = $('<?php /* @noEscape */ echo $code; ?>_cc_type');
        if (['SS','SM','SO'].indexOf(elm.value) != -1) {
            jQuery('#' + '<?php /* @noEscape */ echo $code; ?>_cc_type_ss_div').show().removeClass('ignore-validate');
        } else {
            jQuery('#' + '<?php /* @noEscape */ echo $code; ?>_cc_type_ss_div').hide().addClass('ignore-validate');
        }
    };
    Event.observe($('<?php /* @noEscape */ echo $code; ?>_cc_type'), 'change', SSChecked<?php /* @noEscape */ echo $code; ?>);
    SSChecked<?php /* @noEscape */ echo $code; ?>();
    //]]>

});
            </script>
        </div>
    <?php endif; ?>
</fieldset>
